m4_include([ax_boost_base.m4])

AC_INIT([hsblock],[1.0],[ypark28@jhu.edu])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])

AM_INIT_AUTOMAKE

AC_CHECK_HEADER_STDBOOL
AC_C_RESTRICT
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T

# Checks for header files.
AC_CHECK_HEADERS([stdlib.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_INSTALL
AM_PATH_PYTHON([2.7])
AX_BOOST_BASE([1.40.0])
AC_PROG_MKDIR_P
AC_CHECK_PROG([MKTEMP],[mktemp])
# Checks for library functions.
AC_CHECK_FUNCS([floor pow exp log])

# python modules

dnl macro that checks for specific modules in python
AC_DEFUN([AC_PYTHON_MODULE],
[AC_MSG_CHECKING(for module $1 in python)
echo "import $1" | python -
if test $? -ne 0 ; then
AC_MSG_RESULT(not found)
AC_MSG_ERROR(You need the module $1 available to python for this package)
fi
AC_MSG_RESULT(found)
])

AC_PYTHON_MODULE(sys)
AC_PYTHON_MODULE(os)
AC_PYTHON_MODULE(time)
AC_PYTHON_MODULE(argparse)
AC_PYTHON_MODULE(math)
AC_PYTHON_MODULE(subprocess)
AC_PYTHON_MODULE(networkx)
AC_PYTHON_MODULE(datetime)


# init
AM_INIT_AUTOMAKE([-Wall foreign])

CXXFLAGS="$CXXFLAGS"
CFLAGS="$CFLAGS"

AC_ARG_ENABLE([debug],
              [AS_HELP_STRING([--enable-debug],
	                      [enable debugging info (default is no)])],
              [], [enable_debug=no])
AC_ARG_ENABLE([optim],
              [AS_HELP_STRING([--enable-optim@<:@=0|1|2|3@:>@],
	                      [set optimization level (default is 3)])],
              [if test "x$enable_optim" = xyes; then enable_optim=3; fi],
              [enable_optim=3])

AS_IF([test "x$enable_optim" != xno], 
	    [ext_CFLAGS="$ext_CFLAGS -O$enable_optim "])
AS_IF([test "x$enable_debug" = xyes],
      [debug_CFLAGS="-DDEBUG"],
      [debug_CFLAGS="-DNDEBUG -fomit-frame-pointer -funroll-loops -fforce-addr -fexpensive-optimizations"])

CFLAGS="${generic_CFLAGS} ${ext_CFLAGS} ${user_CFLAGS} ${debug_CFLAGS}"
CXXFLAGS="$CFLAGS"
CXXFLAGS="$CXXFLAGS $BOOST_CPPFLAGS"
LDFLAGS="$user_LDFLAGS"


# makefiles to configure
AC_CONFIG_FILES([Makefile src/Makefile])

# make it happen
AC_OUTPUT
